/**
 * @file
 * @author Ricardo Bustamante de Queiroz <ricardobqueiroz@gmail.com>
 * @version
 *
 * @section LICENSE
 *
 * This file is part of RGine.
 *
 * RGine is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Foobar is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with RGine.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @section DESCRIPTION
 * 
 * File: RPhysicalCylinder.cpp
 * Created on: Aug 5, 2011
 */

#include "RPhysicalCylinder.h"

RPhysicalCylinder::RPhysicalCylinder(REntity *entity, double mass)
    :RPhysicalObject(entity, mass) {
    RVector3f scale = entity->getScale();
    RVector3f minVertex = entity->getBoundingBox().getMinVertex();
    RVector3f maxVertex = entity->getBoundingBox().getMaxVertex();

    float rX = ((maxVertex.x() - minVertex.x())/2.0)*scale.x();
    float rZ = ((maxVertex.z() - minVertex.z())/2.0)*scale.z();
    float h = ((maxVertex.y() - minVertex.y())*scale.y())/2.0;

    initialize(new btCylinderShape(btVector3(rX, h, rZ)));
}
